<?php
/**
 * Created by PhpStorm.
 * User: gyq
 * Date: 2018/10/29
 * Time: 22:15
 */

namespace app\api\controller\v1;


use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\BannerMissException;
use app\api\model\Banner as BannerModel;
class Banner
{
    public function getBanner($id)
    {
        (new IDMustBePositiveInt())->goCheck();
//        返回的是模型
        $banner = BannerModel::getBannerById($id);
        if (!$banner) {
           throw new BannerMissException();
        } else {
            return json($banner,200);
        }
    }
}